function welfare = RamseyHSVObjective(tau,pr,w,pai,pw,G)
% Input  : tau    = tax preter
%          pr     = parameters
%          w      = exp(alpha)
%          pai    = probablity measure
%          G      = government expenditure
% Output : welfare= value of the objective function

lambda = fzero(@(x) RamseyHSVObjectiveFOC(x,tau,pr,w,pai,G),0.85);

temp = pr.sig+tau+pr.gam*(1-tau);

c = lambda^((1+pr.sig)/temp).*(1-tau)^((1-tau)/temp).*pr.Om^(-(1-tau)/temp).*w.^((1-tau)*(1+pr.sig)/temp);  
y = lambda^((1-pr.gam)/temp).*(1-tau)^(1/temp)      .*pr.Om^(-1/temp)      .*w.^((1+pr.sig)/temp);
welfare = sum(pw.*pai.*Utility(c,y,w,pr));

disp([welfare lambda tau])
save lambda lambda
save tau tau
save c c
save y y 
